export default function () {
  return {
    data() {
      return {
      };
    },
    computed: {
      config() {
        return this.data.config;
      },
      width() {
        
        return this.data.w;
      },
      height() {
        return this.data.h;
      },
      showDataIndex() {
        return this.config.dataIndex || 0
      },
      showData() {
        if(!this.data._isInit){
          return null
        }
        if (this.lr_loadDataSourceData) {
          let { dataCode, dataList } = this.config
          if (dataList && dataList.length > 0) {
            dataCode = dataList[this.showDataIndex].dataCode
          }
          if (dataCode) {
            this.lr_loadDataSourceData(dataCode);
            const data = this.lr_dataSourceData[dataCode];
            if (data) {
              return data;
            } else {
              return null;
            }
          }
        }

        return null;
      },
    },
    methods: {
      getEvent(strEvent) {
        // 获取事件方法
        if (!this.$validatenull(strEvent)) {
          strEvent = `(params) => {${strEvent}}`;
          return this.$getFunction(strEvent);
        } else {
          return { res: false, msg: "没设置脚本函数！" };
        }
      },
      handleQClick(index) {
        console.log(index, 'test')
        this.$set(this.config, 'dataIndex', index)
        //this.config.dataIndex = index
      },
      setProp(item, name, value) {
        if (value) {
          item[name] = value
        }
      }

    }
  }
}